search algorithm in python